package scu.maqiang.eigenvalue;

import scu.maqiang.fes.BVPType;
import scu.maqiang.fes.FES2T61;
import scu.maqiang.mesh.Mesh2T3;
import scu.maqiang.mesh.Mesh2T6;
import scu.maqiang.numeric.Direct;
import scu.maqiang.numeric.EigenSSolver;
import scu.maqiang.numeric.MVO;
import scu.maqiang.numeric.SRMatrix;

public class LapEigenValue2DT61 {

	public static void main(String[] args) {
		Mesh2T3 mesh0 = new Mesh2T3().square(50, 50);
		Mesh2T6 mesh = new Mesh2T6(mesh0);
		mesh.scale(Math.PI, Math.PI);
		
		FES2T61 fs = new FES2T61(mesh);
		SRMatrix A = new SRMatrix(fs.GetNdof());
		SRMatrix M = new SRMatrix(fs.GetNdof());
		
		int N = 10;
		double[] D = new double[N];
		double[][] V = new double[N][fs.GetNdof()];
		double[] x = MVO.rand(fs.GetNdof());
		fs.assembleStiff(new double[] {1.0}, BVPType.COMMON, A);
//		A.sort();
//		System.out.println(A);
		fs.assembleMass(new double[] {1.0}, BVPType.LUMP_MASS, M);
		//M.sort();
		//System.out.println(M);
		fs.applyBC_MBN(A, x, Direct.All, 0.0, 1, 2, 3, 4);
		//fs.applyBCZero(A, x, Direct.X, BCType.RCE, 1, 2, 3, 4);
		//System.out.println(A);
		EigenSSolver solver = new EigenSSolver();
		solver.inversePowerTran_DSS(A, M, x, 2.0, N, D, V);
		System.out.println(MVO.toString(D));
		mesh.toTecplot("EigenvaluesT6.dat", V);
	}

}
